//商品管理-商品即秒排期列表
App.util.ns('Admin.Enterprise.Personnel');
App.pages.add((function(){
    var NS = Admin.Enterprise.Personnel;
    var page = new App.Page({
        name: 'enterprise/personnel/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/enterprise/personnel',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                //showId: false,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'gender', title: '性别', width: '80px', items: [
                    [0, '未知'],
                    [1, '男'],
                    [2, '女']
                ]}
            ],
            menu: [
                {parent: 'add', permission: 'op:admin.enterprise.personnel.create'},
                {type: 'globe', permission: 'op:admin.enterprise.personnel', name: '导入表格',
                    operation: function(dataTable){
                    dataTable.wins.get('multiImportWin').show();}
                },
                {parent: 'view', permission: 'op:admin.enterprise.personnel.detail'},
                {parent: 'edit', permission: 'op:admin.enterprise.personnel.update'},
                {parent: 'drop', permission: 'op:admin.enterprise.personnel.delete'},
                {parent: 'multiDrop', permission: 'op:admin.enterprise.personnel.multiDelete'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form),
                }
            },
            after: function(dataTable){
                dataTable.wins.add(new NS.MultiImport(dataTable), 'multiImportWin');
            },
        }, page);
        this.dataTable.fix(this.contentContainer);
    });
    //页面打开
    page.showStack.add('openPage', function(){
        if(this.params){
            var params = this.params;
            //设置面包屑导航
            this.setBreadcrumb([{
                icon: '<i class="fa fa-crosshairs"></i>',
                content: '企业与企业员工'
            }, {
                content: '员工管理',
                action: function(){
                    App.nav.back();
                }
            }, {
                active: true,
                content: '员工所属企业 - ' + params['enterprise_name']
            }]);
            //设置参数
            for(var i in params){
                this.dataTable.param.set(i, params[i]);
            }
            if(this.dataTable.paginator){
                this.dataTable.paginator.currentPage = 1;
            }
            //加载数据
            this.dataTable.loadData();
        }
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());